//
//  TestBankActorTests.swift
//  TestBankActorTests
//
//  Created by 罗万能 on 2025/6/17.
//
@testable import TestBankActor
import Testing
import SwiftData

struct TestBankActorTests {

    @Test func example() async throws {
        // Write your test here and use APIs like `#expect(...)` to check expected conditions.
        
        let schema = Schema([
            Item.self,
            Account.self,
        ])
        let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: true)

        do {
            let container =  try ModelContainer(for: schema, configurations: [modelConfiguration])
            let context = await container.mainContext
            let a1 = Account(balance: 100)
            let a2 = Account(balance: 200)
            let a3 = Account(balance: 50)
            context.insert(a1)
            context.insert(a2)
            context.insert(a3)
            
            
            
            
            
        } catch {
            fatalError("Could not create ModelContainer: \(error)")
        }
        let a1 = BankAccount()
        await a1.deposit(amount: 100)
        let a2 = BankAccount()
        await a2.deposit(amount: 200)
        let transfer = TransfortService()
        await a1withdrow(a1: a1)
       
            await transfer.trans(from: a1, to: a2, amount: 50)
         
       
        await a1.accountInfo()
        await a2.accountInfo()
        try await Task.sleep(for: .seconds(2))
    }
    func a1withdrow(a1: BankAccount) async{
   
            await a1.withdraw(amount: 90)
  
    }

}
